home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / ein / sources / cdpsrc.lzh / CDP / MAIN.C < prev    next >
C/C++ Source or Header  |  1994-09-05  |  12KB  |  408 lines

  1. /*<Header>==============================================================
  2. *
  3. *    ébécâvâîü[âä / "MAIN.C"
  4. *
  5. *        [ EIN(tm) project : âTâôâvâïâvâìâOâëâÇ ]
  6. *
  7. *    COPYRIGHT  Nam  1994, All rights reserved.
  8. *
  9. *    özòtüEægì₧üEëⁿò╧üEÅñùÿùpé╖é╫é─Ä⌐ùRüBé╜é╛é╡û│ò█Å╪é┴é╖
  10. *
  11. *-----------------------------------------------------------------------
  12. *    V1.0L01â┐    94.04.07/Nam    âvâìâgâ^âCâv
  13. *    V1.0L30        94.07.19/Nam    EIN(TM)î÷èJö┼
  14. *    V1.0L31        94.09.05/Nam    GM_QUITÄ₧é╔Ä⌐ò¬é┼WINDOWé≡Å┴ïÄ
  15. *</Header>==============================================================*/
  16. #include    <stdio.h>
  17. #include    <stdlib.h>
  18. #include    <string.h>
  19. #include    <snd.h>
  20. #include    <winb.h>
  21. #include    <te.h>
  22. #include    <fntb.h>
  23. #include    <gui.h>
  24. #include    <egb.h>
  25. //#include    <file_dlg.h>
  26. //#include    <tifflib.h>
  27. #include    <msdos.cf>
  28. #include    <loader.h>
  29. #include    <math.h>
  30. #include    <io.h>
  31. #include    <guidbg.h>
  32. //#include    <wgb.h>
  33. // üª é▒é▒é▄é┼é¬ò╜ï╧ôIé╔Ägùpé│éΩéΘâwâbâ_
  34.  
  35. #include    "..\ein\eintm.h"    // EIN(TM)è╓ÿAâëâCâuâëâèé╠âwâbâ_
  36.  
  37. #define    ERROR    (-1)
  38.  
  39. int        ID_ICON[10];
  40. int        ID_PANEL[20];
  41. int        dispMode = 0;    // 0:ICON / 1:PANEL
  42. int        showTime = 0;    // 0:âgâëâbâNôαëëætÄ₧è╘, 1:âfâBâXâNôαëëætÄ₧è╘, 2:
  43.  
  44. /*= âèâWâàü[âÇùpÉ▌ÆΦ=================================================*/
  45. int        RSM_DISPMODE;
  46. int        RSM_SHOWTIME;
  47. FRAME    RSM_ICONFR;
  48. FRAME    RSM_PANELFR;
  49. // âèâWâàü[âÇâ}âlü[âWââé╔Æ╩Æmé╖éΘüAâAâvâèÄ»ò╩IDüi63ò╢ÄÜê╚ë║é╠uniqé╚ò╢ÄÜù±üj
  50. char    RSMID[]="%%% CDPlayer icon %%%";
  51. // âèâWâàü[âÇÅεò±é╔ûäé▀ì₧é▐â^âCâgâïò╢ÄÜù±üiâ^âXâNâèâXâgé╔éαò╣ùpüj
  52. char    RSMTITLE[]="ébécâvâîü[âä  V0.1 L31";
  53. // âèâWâàü[âÇÅεò±ô╟é▌Åæé½âoâbâtâ@é╠âTâCâYüiâAâvâèî┼ùLâTâCâYé╚é╠é┼Æ▓É«é╡é─é╦üj
  54. #define    RBUFSIZE    (1024)
  55. /*= âèâWâàü[âÇùpÉ▌ÆΦ=================================================*/
  56.  
  57. void    ( *GV_defIdleTask )() ;
  58.  
  59. MMICTRL    mmic = {
  60.                  SCREEN16 | SCREENIGNORE,        //    resolution
  61.                  SCREENUNUSED,
  62.                  0, SCREENAVAILABLE, 0,    //    write_page,display_page,priority
  63.                  SCREENAVAILABLE,    //    mode
  64.                  SCREENEXPAND,        //    vram_x
  65.                  0,0,0,0,            //    size,*ptr,asize,*atpr
  66.                  0,0,0,0,            //    frame
  67.                  -32767,            //    move
  68.                  -32767,
  69.                   32767,
  70.                   32767,
  71.                  15,8,7,15            //    color
  72.                 } ;
  73.  
  74. /*===================================================================*/
  75. /*  âüâCâôâïü[âv                                                     */
  76. /*===================================================================*/
  77. void main()
  78. {
  79.     extern int APL_init() ;
  80.  
  81.     int        kobj;
  82.  
  83.     //    Åëè·ë╗Åêù¥
  84.     if (MMI_Open( &mmic ) == NOERR){
  85.         // ô±ÅdïNô«é╠check
  86.         if ( (kobj = MMI_CallMessage( MMI_GetApliId(), GM_QUERYID, QM_KIND, 1)) > NOERR ){
  87.             MMI_CallMessage( MMI_GetApliId(), GM_SWITCH, FALSE, kobj );
  88.         } else {
  89.             // âAâCâhâïâ^âXâNé╔ôoÿ^
  90.             setIdleTask() ;
  91.             // Åëè·ë╗é╔ɼî≈é╖éΩé╬âüâCâôâïü[âvé╔ôⁿéΘ.
  92.             if ( APL_init()==NOERR ){
  93.                 MMI_ExecSystem();
  94.             }
  95.             // âAâCâhâïé╠ë≡Å£
  96.             resetIdleTask();
  97.             // âEâBâôâhâDÅ┴ïÄ(üªSHELLé╔Å┴ïÄé│é╣éΘé╞Æxéóé╠é┼)
  98.             eraseWin();
  99.         }
  100.     }
  101.     // ÅIù╣Åêù¥
  102.     MMI_Close() ;
  103. }
  104.  
  105. /*===================================================================*/
  106. /*  Åëè·ë╗Åêù¥                                                       */
  107. /*===================================================================*/
  108. int APL_init()
  109. {
  110.     extern    int        clearCDstat();
  111.     extern    int        updateCDdisp();        // gui.c
  112.     extern    int        userFunc();
  113.     
  114.     extern    MMIINIT    initDataRES_ICON ;
  115.     extern    MMIINIT    initDataRES_PANL ;
  116.  
  117.     extern    int ICONmaxId;
  118.     extern    unsigned char *ICONTbl[];
  119.  
  120.     char    work[RSMWORKSIZE];    // âèâWâàü[âÇâ}âlü[âWââé╠âÅü[âNâGâèâA
  121.     char    buf[RBUFSIZE];
  122.     char    *ptr;
  123.     int        size, x, y;
  124.     HYPER    hyp;
  125.     register int    ret ;
  126.  
  127.     if ((ret = MMI_initHyper()) < 0)            //    ânâCâpü[î^
  128.         return ret;
  129.     if ((ret = MMI_initDialogL40()) < 0)        //    â_âCâAâìâOî^
  130.         return ret;
  131. //    if ((ret = MMI_initAlertL40()) < 0)            //    âAâëü[âgî^
  132. //        return ret;
  133.     if ((ret = MMI_initMessageL40()) < 0)        //    âüâbâZü[âWî^
  134.         return ret;
  135. //    if ((ret = MMI_initMenuL40()) < 0)            //    âüâjâàü[î^
  136. //        return ret;
  137.     if ((ret = MMI_initButtonL40()) < 0)        //    â{â^âôî^
  138.         return ret;
  139.     if ((ret = MMI_initDrawButtonL40()) < 0)    //    âhâìâEâ{â^âôî^
  140.         return ret;
  141. //    if ((ret = MMI_initToggleIconL40()) < 0)    //    âgâOâïâ{â^âôî^
  142. //        return ret;
  143.     if ((ret = MMI_initIconL40()) < 0)            //    âAâCâRâôî^
  144.         return ret;
  145. //    if ((ret = MMI_initScrollBarL40()) < 0)        //    âXâNâìü[âïâoü[î^
  146. //        return ret;
  147. //    if ((ret = MMI_initTextL40()) < 0)            //    âeâLâXâgî^
  148. //        return ret;
  149. //    if ((ret = MMI_initMenuItemL40()) < 0)        //    âüâjâàü[âAâCâeâÇî^
  150. //        return ret;
  151.     if ((ret = MMI_initWindowL40()) < 0)        //    âEâBâôâhâEî^
  152.         return ret;
  153.  
  154.     //    âfü[â^é╠ôoÿ^
  155.     if ((ret = MMI_Init(&initDataRES_ICON)) < 0)
  156.         return ret ;
  157.     if ((ret = MMI_Init(&initDataRES_PANL)) < 0)
  158.         return ret ;
  159.  
  160.     /*----------------------------------*/
  161.     /*    âAâCâRâôôoÿ^                    */
  162.     /*----------------------------------*/
  163.     MMI_SetIconTable( ICONTbl, ICONmaxId ) ;
  164.  
  165.     // 256,32ké╠Ä₧é╠GUIÉFé≡É▌ÆΦ
  166.     EIN_initGuiColor();
  167.  
  168.     //    âXâCâbâ`ââü[æ╬ë₧è╓Éöé╠ôoÿ^
  169.     MMI_SendMessage( MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc ) ;
  170.  
  171.     //    â^âCâgâïé╠ôoÿ^
  172.     MMI_CallMessage( MMI_GetApliId(), GM_TITLE, (int)RSMTITLE, 0 ) ;
  173.  
  174.     /*----------------------------------*/
  175.     /*    âèâWâàü[âÇô╟é▌ì₧é▌ (üªé╠é┬éóé╜Åêù¥é═òKé╕ìsé┴é─é¡é╛é│éó)    */
  176.     /*----------------------------------*/
  177.     // üªâèâWâàü[âÇâ}âlü[âWââé╠Åëè·ë╗(âAâvâèé╠IDâ^âOôoÿ^)
  178.     EIN_rsmInit( work, RSMID );
  179.     // üªô╟é▌ì₧é▌âoâbâtâ@É▌ÆΦ
  180.     EIN_rsmBufSet( work, buf, RBUFSIZE );
  181.     // üªâèâWâàü[âÇÅεò±ô╟é▌ì₧é▌
  182.     size = EIN_rsmLoad( work );
  183.     #ifdef DEBUG
  184.     printf(" resume size(%d)\n",size);
  185.     #endif
  186.     if ( size > 0 ){
  187.         // ò\Īâéü[âh( 0:ICON / 1:PANEL,  ... )
  188.         if (((ptr = strstr(buf,"\nMODE: ")) != NULL ) &&
  189.             (sscanf(ptr,"\nMODE: %d %d\n", &x, &y) > 1 ) ){
  190.             dispMode = ( (x<0)||(x>1) ) ?0 :x;
  191.             showTime = ( (y<0)||(y>2) ) ?0 :y;
  192.             RSM_DISPMODE = dispMode;
  193.             RSM_SHOWTIME = showTime;
  194.         }
  195.         // ICONò\Īê╩Æu
  196.         if (((ptr = strstr(buf,"\nICON: ")) != NULL ) &&
  197.             (sscanf(ptr,"\nICON: %d %d\n", &x, &y) > 1 ) ){
  198.             MMI_SendMessage( ID_ICON[0], MM_GETHYPER, 1, &hyp );    // ÿgì└òWé≡ô╛éΘ
  199.             RSM_ICONFR.lupx = x;
  200.             RSM_ICONFR.lupy = y;
  201.             RSM_ICONFR.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
  202.             RSM_ICONFR.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
  203.             #ifdef DEBUG
  204.             printf("ICON: move to (%d,%d)\n", x, y);
  205.             #endif
  206.             if ( x<-31 ){
  207.                 x=0;
  208.             }
  209.             if ( y<-31 ){
  210.                 y=0;
  211.             }
  212.             MMI_SendMessage( ID_ICON[0], MM_MOVE, 1, &RSM_ICONFR ) ;
  213.         }
  214.         // PANELò\Īê╩Æu
  215.         if (((ptr = strstr(buf,"\nPANEL: ")) != NULL ) &&
  216.             (sscanf(ptr,"\nPANEL: %d %d\n", &x, &y) > 1 ) ){
  217.             MMI_SendMessage( ID_PANEL[0], MM_GETHYPER, 1, &hyp );    // ÿgì└òWé≡ô╛éΘ
  218.             RSM_PANELFR.lupx = x;
  219.             RSM_PANELFR.lupy = y;
  220.             RSM_PANELFR.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
  221.             RSM_PANELFR.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
  222.             #ifdef DEBUG
  223.             printf("PANEL: move to (%d,%d)\n", x, y);
  224.             #endif
  225.             if ( (x>=0)&&(x<1024)&&(y>=0)&&(y<712) ){
  226.                 MMI_SendMessage( ID_PANEL[0], MM_MOVE, 1, &RSM_PANELFR ) ;
  227.             }
  228.         }
  229.     } else {
  230.         #ifdef DEBUG
  231.         printf("Can't find resume file.\n");
  232.         #endif
  233.     }
  234.  
  235.     //    âEâBâôâhâEù▐é≡ATTACHé╖éΘ
  236.     if ( dispMode == 0 ){
  237.         MMI_SendMessage( ID_ICON[0], MM_ATTACH, 1, MMI_GetBaseObj() ) ;
  238.     } else {
  239.         MMI_SendMessage( ID_PANEL[0], MM_ATTACH, 1, MMI_GetBaseObj() ) ;
  240.     }
  241.  
  242.     //    öwîié≡ò\Īé╖éΘ
  243.     MMI_SendMessage( MMI_GetBaseObj(), MM_SHOW, 0 ) ;
  244.  
  245.     // CDÅεò±é≡ò\Ī
  246.     clearCDstat();
  247.     updateCDdisp( 1 );
  248.  
  249.     return NOERR ;
  250. }
  251.  
  252. /*===================================================================*/
  253. /* âèâWâàü[âÇÅεò±ìXÉV (üªé¬é┬éóé╜Åêù¥é═òKé╕ìsé┴é─ë║é│éó)             */
  254. /*===================================================================*/
  255. void    SaveResumeFile()
  256. {
  257.     char    work[RSMWORKSIZE];
  258.     
  259.     char    buf[RBUFSIZE];
  260.     char    aplpath[128];
  261.     HYPER    hyp1,hyp2;
  262.     
  263.     int        ret;
  264.     
  265.     // ÿgì└òWé≡ô╛éΘ
  266.     MMI_SendMessage( ID_ICON[0], MM_GETHYPER, 1, &hyp1 );
  267.     MMI_SendMessage( ID_PANEL[0],MM_GETHYPER, 1, &hyp2 );
  268.     // ò╧ë╗é╡é─éóé╜éτâZü[âu
  269.     if ( (RSM_DISPMODE     != dispMode )||
  270. //         (RSM_SHOWTIME     != showTime )||
  271.          (RSM_ICONFR.lupx  != hyp1.fr.lupx)||
  272.          (RSM_ICONFR.lupy  != hyp1.fr.lupy)||
  273.          (RSM_PANELFR.lupx != hyp2.fr.lupx)||
  274.          (RSM_PANELFR.lupy != hyp2.fr.lupy) ){
  275.         // üªâ}âlü[âWââÅëè·ë╗
  276.         EIN_rsmInit( work, RSMID );
  277.         // üªâoâbâtâ@É▌ÆΦ(âAâvâè